<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
	<base href="<%=basePath%>">
	<!-- jsp文件头和头部 -->
	<%@ include file="../../system/admin/top.jsp"%> 
	</head>
	<body>
		<div class="container-fluid" id="main-container" >
			<div id="page-content" class="clearfix" style="padding-left:2px;">
	  			<div class="row-fluid">
					<div class="row-fluid">
						<!-- 检索  -->
						<form action="rk/list.do" method="post" name="rkForm" id="rkForm">
							<table>
								<tr>
									<td>
										<span class="input-icon">
											<input autocomplete="off" id="gjz" type="text" name="gjz"  placeholder="这里输入关键字" style="width: 200px;"/>
											<i id="nav-search-icon" class="icon-search"></i>
										</span>
									</td>
									<td><input class="span10 date-picker" name="beginTime" id="beginTime"  type="text" data-date-format="yyyy-mm-dd" readonly="readonly" style="width:88px;" placeholder="开始日期" /></td>
									<td><input class="span10 date-picker" name="endTime" name="endTime"  type="text" data-date-format="yyyy-mm-dd" readonly="readonly" style="width:88px;" placeholder="结束日期" /></td>
									<c:if test="${QX.cha == 1 }">
									<td style="vertical-align:top;"><button class="btn btn-mini btn-light" onclick="search();" title="检索"><i id="nav-search-icon" class="icon-search"></i></button></td>
									</c:if>
								</tr>
							</table>
						<!-- 检索  -->
							<table id="table_report" class="table table-striped table-bordered table-hover">
								<thead>
									<tr>
										<th class="center">
										<label><input type="checkbox" id="zcheckbox" /><span class="lbl"></span></label>
										</th>
										<th hidden="hidden">id</th>
										<th>单号</th>
										<th hidden="hidden">药品id</th>
										<th>药品编码</th>
										<th>药品名称</th>
										<th hidden="hidden">药品拼音码</th>
										<th>药品类型</th>
										<th>药品单位</th>
										<th>药品单价</th>
										<th>药品用法</th>
										<th>入库数量</th>
										<th hidden="hidden">入库操作人id</th>
										<th>入库时间</th>
										<th hidden="hidden">门诊id</th>
										<th hidden="hidden">标识</th>
										<th class="center">操作</th>
									</tr>
								</thead>
								<tbody>
									<!-- 开始循环 -->	
									<c:choose>
										<c:when test="${not empty listAll}">
											<c:if test="${QX.cha == 1 }">
												<c:forEach items="${listAll}" var="rk" varStatus="vs">
													<tr>
														<td class='center' style="width: 30px;">
															<label><input type='checkbox' name='ids' id="" value="${rk.id}"/><span class="lbl"></span></label>
														</td>
														<td hidden="hidden">${rk.id}</td>
														<td>${rk.code}</td>
														<td hidden="hidden">${rk.ypid}</td>
														<td>${rk.ypcode}</td>
														<td>${rk.ypname}</td>
														<td hidden="hidden">${rk.ypspell}</td>
														<td>${rk.yptype}</td>
														<td>${rk.ypunit}</td>
														<td>${rk.price}</td>
														<td>${rk.ypusage}</td>
														<td>${rk.incount}</td>
														<td hidden="hidden">${rk.czrid}</td>
														<td>${rk.indate}</td>
														<td hidden="hidden">${rk.mzid}</td>
														<td hidden="hidden">${rk.bs}</td>								
														<td style="width: 60px;">
															<div class='hidden-phone visible-desktop btn-group'>
																<c:if test="${QX.edit == 1 }">
																	<a class='btn btn-mini btn-info' title="显示入库详情" onclick="edit('${rk.id}');">入库详情</a>
																</c:if>
																<a class='btn btn-mini btn-danger' title="删除" onclick="del('${rk.id}');">删除</a>			
															</div>
														</td>
													</tr>
												</c:forEach>
											</c:if>
											<c:if test="${QX.cha == 0 }">
												<tr>
													<td colspan="10" class="center">您无权查看</td>
												</tr>
											</c:if>
										</c:when>
										<c:otherwise>
											<tr class="main_info">
												<td colspan="20" class="center">没有相关数据</td>
											</tr>
										</c:otherwise>
									</c:choose>
								</tbody>
							</table>
							<div class="page-header position-relative">
								<table style="width:100%;">
									<tr>
										<td style="vertical-align:top;">
											<c:if test="${QX.add == 1 }">
											<a class="btn btn-small btn-success" onclick="add();">新增</a>
											</c:if>				
										</td>
										<td style="vertical-align:top;"><div class="pagination" style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div></td>
									</tr>
								</table>
							</div>
						</form>
					</div>
					<!-- PAGE CONTENT ENDS HERE -->
	  			</div><!--/row-->
			</div><!--/#page-content-->
		</div><!--/.fluid-container#main-container-->
		
		<!-- 返回顶部  -->
		<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse">
			<i class="icon-double-angle-up icon-only"></i>
		</a>
			
		<!-- 引入 -->
		<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
		<script src="static/js/bootstrap.min.js"></script>
		<script src="static/js/ace-elements.min.js"></script>
		<script src="static/js/ace.min.js"></script>
		
		<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 下拉框 -->
		<script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
		<script type="text/javascript" src="static/js/bootbox.min.js"></script><!-- 确认窗口 -->
		<script type="text/javascript" src="static/js/jquery.tips.js"></script><!--提示框-->
		<script type="text/javascript">
			$(top.hangge());
			
			//检索
			function search(){
				top.jzts();
				$("#rkForm").submit();
			}
			
			//新增
			function add(){
				 top.jzts();
				 var diag = new top.Dialog();
				 diag.Drag=true;
				 diag.Title ="新增药品入库";
				 diag.URL = '<%=basePath%>rk/goAdd.do';
				 diag.Width = 1000;
				 diag.Height = 800;
				 diag.CancelEvent = function(){ //关闭事件
					 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
						if('${page.currentPage}' == '0'){
							 top.jzts();
							 setTimeout("self.location=self.location",100);
						 }else{
							 nextPage(${page.currentPage});
						 }
					}
					diag.close();
				 };
				 diag.show();
			}
			
			//修改
			function edit(id){
				 top.jzts();
				 var diag = new top.Dialog();
				 diag.Drag=true;
				 diag.Title ="药品入库详情";
				 diag.URL = "<%=basePath%>rk/goEdit.do?id="+id;
				 diag.Width = 1000;
				 diag.Height = 450;
				 diag.CancelEvent = function(){ //关闭事件
					 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
						 if('${page.currentPage}' == '0'){
							 top.jzts();
							 setTimeout("self.location=self.location",100);
						 }else{
							 nextPage(${page.currentPage});
						 }
					}
					diag.close();
				 };
				 diag.show();
			}
			
			//删除
			function del(id){
				bootbox.confirm("删除本条数据，药品会减少相应删除的库存！确定要删除吗?", function(result) {
					if(result) {
						top.jzts();
						var url = "<%=basePath%>rk/delete.do?id="+id;
						$.get(url,function(data){
							nextPage(${page.currentPage});
						});
					}
				});
			}
					
		</script>
			
		<script type="text/javascript">
			$(function() {
				//日期框
				$('.date-picker').datepicker();
				
				//下拉框
				$(".chzn-select").chosen(); 
				$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
				
				//复选框
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
				});
				
			});
		</script>
	</body>
</html>